
export default{
    data(){
        return {
			imgurl:'',
			wallet:{
				status:false,
				address:''
			},
			//分享
            myShare:{
                title:'',
                desc:'',
                imgUrl:'',
                link:''
            },
        }
    },
	async onLoad(options){
		this.imgurl = await this.func.$getCon('imgurl')
		if(options.s_address){
			uni.setStorageSync('s_address',options.s_address);
		};
		await this.checkLogin();
	},
	methods: {
		//检查登录状态
		async checkLogin()
		{
			if(uni.getStorageSync("token")!='')
			{
				this.wallet.status=true;
				this.wallet.address= uni.getStorageSync("token");
				return true;
			}
			return false;

		},
		//设置返回路径
		//address_back_url 选择地址之后的返回
		//nologin_back_url 登录之后的返回
		//cshou_back_url   收银之后的返回
		async setComBackUrl(type='address_back_url',url=''){
			uni.removeStorageSync(type);
			if(url){
				uni.setStorageSync(type,url)
				return
			}
			let page = await this.getPageInfo()
			uni.setStorageSync(type,page.curUrl)
		},
		//获取页面信息
		async getPageInfo(){
			let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
			let curRoute = routes[routes.length - 1].route //获取当前页面路由
			let curParam = routes[routes.length - 1].options; //获取路由参数
			// 拼接参数
			let param = ''
			for (let key in curParam) {
				param += '&' + key + '=' + curParam[key]
			}
			let data = {}
			data.curRoute = curRoute
			data.curParam = curParam
			if(param){
				param = param.substr(1);
				data.curUrl = curRoute+'?'+param;
			}else{
				data.curUrl = curRoute;
			}
			data.curUrl ="/"+data.curUrl
			return data;
		}
	}
}
